import syllabus from '../../service/index.service'
import config from '../../config'
const app = getApp()

Page({

  data: {
    userid: '', // 用户id
    username: '', // 用户名称
    role: '', // 用户身份 弓箭爱好者-1;学员-2;射手-3;教练-4;管理员-5;
    page: 1,
    pagenum: 5,
    activeTab: 0, // 当前选中tab下标
    viewTabs: [], // 页面最终使用到的tab栏信息
    bassTabs: [ // 公用-tab栏
      { title: '课程列表', anchor: 0 },
      { title: '班级列表', anchor: 4 }
    ],
    liMuTabs: [ // 公用-tab栏
      { title: '课程列表', anchor: 0 },
      { title: '扫一扫', anchor: 3 }
    ],
    manageTabs: [ // 教练/管理身份-tab栏
      { title: '课程列表', anchor: 0 },
      { title: '班级列表', anchor: 4 },
      { title: '创建班级', anchor: 5 },
      { title: '发布课程', anchor: 1 },
      { title: '删除课程', anchor: 2 },
      { title: '扫一扫', anchor: 3 }
    ],
    manageIndexs: [4,5], // 属于管理组的对应序号
    dataList: [], // 课程/班级列表数据
    modalTitle: '', // modal主标题
    modalSubTitle: '', // modal副标题
    modalOpened: false, // modal是否打开
    modalCallback: null, // modal确认点击按钮回调事件
    modalBtnTextArr: [ // 定义modal按钮文案
      { text: '取消' },
      { text: '确认'}
    ],
    qrcodeImg: '', // 签到二维码img
    qrcodeMaskOpened: false, // 二维码modal是否打开
    courseTypeArr: ['公开训练','学员训练','积分训练'], // 课程类型 0-公开训练;1-学员训练；2-积分训练
    activeCourseTypeIndex: 0, // 当前选中的课程类型  0-公开训练;1-学员训练；2-积分训练
    isPushMsgArr: ['开课前6小时通知','立即通知'], // 是否推送钉钉消息 0-不推送;1-推送
    isPushMsgIndex: 0, // 是否选择推送消息默认不推送 /*  */
    ceratedCourseTitle: '', // 发布课程名称
    ceratedCourseMaxPeople: '', // 发布课程的最大参与人数 
    ceratedCourseStartTime: '', // 发布课程开始时间
    ceratedCourseEndTime: '', // 发布课程结束时间
    ceratedClassesNumber: '', // 创建班级-班级号
    ceratedClassesName: '',  // 创建班级-班级名称
    ceratedClassesTeacherName: '',  // 创建班级-班级老师
    serverTime: '', // 服务器时间
    //新增参数是否需要发送消息通知
    isPushMsg:false,
    onPopup: false, // 报名列表/班级人员列表浮层是否打开，默认不打开 false-不打开;true-打开
    signInListData: [], // 报名列表/班级人员列表数据
    userRankInfoModal: false, // 用户设置打榜信息弹窗
    userScore: '', // 用户打榜积分
    userRankId: null, // 用户打榜id
  },

  onLoad() {
    let that = this
    that.setData({
      userid: app.globalData.userInfo.userId,
      username: app.globalData.userInfo.userName,
      role: app.globalData.userInfo.role,
      serverTime: app.globalData.serverTime
    })

    if (that.data.manageIndexs.indexOf(that.data.role) > -1) {
        that.setData({
          viewTabs: that.data.manageTabs
        })
    }else if(that.data.role == 0){
        that.setData({
          viewTabs: that.data.liMuTabs
        })
    }else {
      that.setData({
        viewTabs: that.data.bassTabs
      })
    }

    app.methods.checkLogin((isLogin) => {
      if (isLogin) {
        that.getList()
        // setTimeout(function() {
        //   that.studentAdd()
        // }, 3000)
        // that.add()
        // that.apply()
        // that.cancel()
        // that.delete()
        // that.sign()
      }
    })
  },

  onShow() {
    // dd.showLoading()

    // let params = {
    //   id: '17',
    //   teacherUid: '6014676'
    // }

    // let success = function (res) {
    //   console.log(res)
    //   dd.showToast({
    //     type: 'success',
    //     content: '认证成功'
    //   })
    // }

    // let fail = function (msg) {
    //    dd.showToast({
    //     type: 'fail',
    //     content: msg
    //   })
    // }

    // setTimeout(function() {
    //   dd.hideLoading()
    //   syllabus.authentication(params, success, fail)
    // }, 800)
  },

  /**
   * 获取课表/班级列表信息
   */
  getList(type) {
    let that = this

    if (type == 'next') { // 下拉触底加载下一页
      that.data.page = that.data.page + 1
    } else {
      that.data.page = 1
    }

    let params = {
      dingTalkUserId: that.data.userid,
      pageNo: that.data.page,
      pageSize:that.data.pagenum
    }

    let success = function (res) {
      if (type == 'next') {
        if (res.data.result.datas.length > 0) {
          that.setData({
            dataList: that.data.dataList.concat(res.data.result.datas)
          })
        }
        
        else {
          dd.showToast({
            type: 'none',
            content: '暂无更多数据'
          })
        }
        
      } else {
        that.setData({
          dataList: res.data.result.datas
        })
      }
    }

    let fail = function (msg) {
      dd.showToast({
          type: 'fail',
          content: msg
        })
    }

    if (that.data.manageTabs[that.data.activeTab].anchor == 0 || 
        that.data.manageTabs[that.data.activeTab].anchor == 2) { // 课程列表/删除课程列表
          syllabus.get(params, success, fail)
    } else if (that.data.manageTabs[that.data.activeTab].anchor == 4) { // 班级列表
        syllabus.classesList(params, success, fail)
    }
  },

  /**
   * 添加课表/创建班级
   */
  add() {
    let that = this
    let push = that.data.isPushMsgIndex == 1;
    let params = {
      startTime: that.data.ceratedCourseStartTime,
      endTime: that.data.ceratedCourseEndTime,
      maxPeople: that.data.ceratedCourseMaxPeople,
      title: that.data.ceratedCourseTitle,
      type: that.data.activeCourseTypeIndex,
      dingTalkUserId: that.data.userid,
      isPushMsg: push,
      teacher: that.data.manageTabs[that.data.activeTab].anchor == 5 ? that.data.ceratedClassesTeacherName : that.data.username,
      indexNum: that.data.ceratedClassesNumber,
      name: that.data.ceratedClassesName
    }

    let success = function (res) {
      dd.showToast({
        type: 'success',
        content: that.data.manageTabs[that.data.activeTab].anchor == 5 ? '开班成功' : '发布成功'      
      })

      that.initReleaseData()
    }

    let fail = function (msg) {
      dd.showToast({
        type: 'fail',
        content: msg
      })
    }

    if (that.data.manageTabs[that.data.activeTab].anchor == 5) {
      syllabus.createClasses(params, success, fail)
    } else {
      syllabus.add(params, success, fail)
    }
  },

  /**
   * 加入班级
   */
  studentAdd(e) {
    let that = this

    let indexs = e.target.dataset.indexs

    if (indexs) {
      indexs = indexs + ',' + that.data.userid + ','
    } else {
      indexs = that.data.userid + ','
    }

    // let indexs = '012333630645672687,1844652736858142,'
    // let id = '6014658'

    
    let params = {
      id: e.target.dataset.id,
      // id: id,
      extData: indexs
    }

    let success = function (res) {
      dd.showToast({
        type: 'success',
        content: '加入成功',
        complete: () => {
          that.getList()
        }
      })
    }

    let fail = function (msg) {
      dd.showToast({
        type: 'fail',
        content: msg,
        complete: () => {
          that.getList()
        }
      })
    }

    if (app.methods.enableButtonClicked()) {
      that.openModal({
        title: '提示',
        subtitle: '您确定要加入此班级?',
        cb: function () {
          syllabus.studentListUpdate(params, success, fail)
        }
      })
    }
  },

  /**
   * 退出班级-学员自愿
   */
  studentDelete(e) {
    let that = this

    let indexs = e.target.dataset.indexs.split(',')

    indexs.some((item, i) => {
      if (item == that.data.userid) {
        indexs.splice(i, 1);
        indexs = indexs.join(',')
        return true
      }
    })

    if (indexs) {
      indexs = indexs + ','
    }

    let params = {
      id: e.target.dataset.id,
      extData: indexs
    }

    let success = function (res) {
      dd.showToast({
        type: 'success',
        content: '退出成功',
        complete: () => {
          that.getList()
        }
      })
    }

    let fail = function (msg) {
      dd.showToast({
        type: 'fail',
        content: msg,
        complete: () => {
          that.getList()
        }
      })
    }

    if (app.methods.enableButtonClicked()) {
      that.openModal({
        title: '提示',
        subtitle: '您确定要退出此班级?',
        cb: function () {
          syllabus.studentListUpdate(params, success, fail)
        }
      })
    }
  },

  /**
   * 退出班级-管理员通过列表移除
   */
  studentDeleteManage(e) {
    let that = this

    let fn = function () {
      let classesid = e.target.dataset.classesid
      let userid = e.target.dataset.userid
      let indexs = []
      let signInListDataBefore = that.data.signInListData

      that.data.signInListData.some((item, i) => {
        if (item.userid == userid) {
          that.data.signInListData.splice(i, 1);
          return true
        }
      })

      for (let i = 0; i < that.data.signInListData.length; i++) {
        indexs.push(that.data.signInListData[i]['userid'])
      }
      indexs = indexs.join(',')
      indexs = indexs + ','

      let params = {
        id: classesid,
        extData: indexs
      }

      let success = function (res) {
        dd.showToast({
          type: 'success',
          content: '移除成功',
          complete: () => {
            that.getList()
            that.setData({
              signInListData: that.data.signInListData
            })
            if (that.data.signInListData.length <= 0) {
              that.setData({
                onPopup: false
              })
            }
          }
        })
      }

      let fail = function (msg) {
        dd.showToast({
          type: 'fail',
          content: msg,
          complete: () => {
            that.data.signInListData = signInListDataBefore
          }
        })
      }

      syllabus.studentListUpdate(params, success, fail)
    }

    if (app.methods.enableButtonClicked()) {
      that.openModal({
        title: '提示',
        subtitle: '您确定要移除此学员?',
        cb: function () {
          fn()
        }
      })
    }


    // indexs.some((item, i) => {
    //   if (item == that.data.userid) {
    //     indexs.splice(i, 1);
    //     indexs = indexs.join(',')
    //     return true
    //   }
    // })

    // if (indexs) {
    //   indexs = indexs + ','
    // }

    // let params = {
    //   id: e.target.dataset.id,
    //   extData: indexs
    // }

    // let success = function (res) {
    //   dd.showToast({
    //     type: 'success',
    //     content: '退出成功',
    //     complete: () => {
    //       that.getList()
    //     }
    //   })
    // }

    // let fail = function (msg) {
    //   dd.showToast({
    //     type: 'fail',
    //     content: msg,
    //     complete: () => {
    //       that.getList()
    //     }
    //   })
    // }
  },

  /**
   * 删除课表
   */
  delete(e) {
    let that = this
    let params = {
      courseId: e.target.dataset.id,
      dingTalkUserId: that.data.userid
    }

    let success = function (res) {
      dd.showToast({
        type: 'success',
        content: '删除成功',
        complete: () => {
          that.getList()
        }
      })
    }

    let fail = function (msg) {
      dd.showToast({
        type: 'fail',
        content: msg,
        complete: () => {
          that.getList()
        }
      })
    }

    if (app.methods.enableButtonClicked()) {
      that.openModal({
        title: '提示',
        subtitle: '您确定要删除此课程?',
        cb: function () {
          syllabus.delete(params, success, fail)
        }
      })
    }
  },

  /**
   * 申请报名
   */
  apply(e) {
    let that = this
    let params = {
      courseId: e.target.dataset.id,
      dingTalkUserId: that.data.userid
    }

    let success = function (res) {
      dd.showToast({
        type: 'success',
        content: '报名成功',
        complete: () => {
          that.getList()
        }
      })
    }

    let fail = function (msg) {
      dd.showToast({
        type: 'fail',
        content: msg,
        complete: () => {
          that.getList()
        }
      })
    }

    if (app.methods.enableButtonClicked()) {
      let contextMsg = '您确定要报名此课程?';
      if(e.target.dataset.type == 2){
        contextMsg = '您报名的是积分课程，需要花费您10个积分请确认'
      }
      that.openModal({
        title: '提示',
        subtitle: contextMsg,
        cb: function () {
          syllabus.apply(params, success, fail)
        }
      })
    }
  },

  /**
   * 取消报名
   */
  cancel(e) {
    let that = this
    let params = {
      courseId: e.target.dataset.id,
      dingTalkUserId: that.data.userid
    }

    let success = function (res) {
      dd.showToast({
        type: 'success',
        content: '取消成功',
        complete: () => {
          that.getList()
        }
      })
    }

    let fail = function (msg) {
       dd.showToast({
        type: 'fail',
        content: msg,
        complete: () => {
          that.getList()
        }
      })
    }

    if (app.methods.enableButtonClicked()) {
      that.openModal({
        title: '提示',
        subtitle: '您确定要取消报名?',
        cb: function () {
          syllabus.cancel(params, success, fail)
        }
      })
    }
  },

  /**
   * 获取签到二维码
   */
  qrcode(e) {
    let that = this
    that.setData({
        qrcodeImg: config.domain + '/signup/createSignupERPic?' + 'courseId=' + e.target.dataset.id + '&studentUserId=' + that.data.userid + '&type=0',
        qrcodeMaskOpened: true
    })

    // let params = {
    //   courseId: e.target.dataset.id,
    //   studentUserId: that.data.userid
    // } 

    // let success = function (res) {
      
    //   that.setData({
    //     qrcodeMaskOpened: true
    //   })
    // }

    // let fail = function (msg) {
    //    dd.showToast({
    //     type: 'fail',
    //     content: msg
    //   })
    // }

    // if (app.methods.enableButtonClicked()) {
    //   syllabus.qrcode(params, success, fail)
    // }
  },

   /**
   * 立木核销
   */
  limuHX(opts) {
    dd.showLoading()

    let params = {
      tenantId: app.globalData.userInfo.tenantId,
      teacherDingId: app.globalData.userInfo.userId,
      studentUserId: opts && opts.userId ? opts.userId : ''
    }

    let success = function (res) {
      dd.showToast({
        type: 'success',
        content: '核销成功'
      })
    }

    let fail = function (msg) {
       dd.showToast({
        type: 'fail',
        content: msg
      })
    }

    setTimeout(function() {
      dd.hideLoading()
      syllabus.limuHX(params, success, fail)
    }, 800)
  },

  /**
   * 签到
   */
  sign(opts) {
    dd.showLoading()

    let params = {
      courseId: opts && opts.courseId ? opts.courseId : '',
      teacherDingId: app.globalData.userInfo.userId,
      studentUserId: opts && opts.studentUserId ? opts.studentUserId : ''
    }

    let success = function (res) {
      dd.showToast({
        type: 'success',
        content: '签到成功'
      })
    }

    let fail = function (msg) {
       dd.showToast({
        type: 'fail',
        content: msg
      })
    }

    setTimeout(function() {
      dd.hideLoading()
      syllabus.sign(params, success, fail)
    }, 800)
  },

  /**
   * 打榜认证
   */
  rankingCheck(opts) {
    let that = this
     dd.showLoading()

    let params = {
      id: opts && opts.id ? opts.id : '',
      teacherUid: opts && opts.teacherUid ? opts.teacherUid : '',
      sort: opts && opts.sort ? opts.sort  : ''
    }

    let success = function (res) {
      that.setData({
        userRankInfoModal: false
      })
      dd.showToast({
        type: 'success',
        content: '认证成功'
      })
    }

    let fail = function (msg) {
       dd.showToast({
        type: 'fail',
        content: msg
      })
    }

    setTimeout(function() {
      dd.hideLoading()
      syllabus.authentication(params, success, fail)
    }, 800)
  },

  /**
   * 查看班级人数列表
   */
  lookClassesPerson(opts) {

    let that = this

    if (!opts.target.dataset.istap) {
      return
    }

    let params = {
      id: opts.target.dataset.id,
    }

    let success = function (res) {

      that.data.signInListData = []

      let names = res.data.result
      let id = opts.target.dataset.id

      for (let i in names) {
        that.data.signInListData.push({
          userid: i,
          username: names[i],
          classesid: id
        })
      }

      that.setData({
        signInListData: that.data.signInListData
      })

      that.onPopupToggle()
    }

    let fail = function (msg) {
       dd.showToast({
        type: 'fail',
        content: msg
      })
    }

    if (app.methods.enableButtonClicked()) {
      syllabus.getStudentName(params, success, fail)
    }
  },

   /**
   * 查看报名列表
   */
  signInList(opts) {
    let that = this

    if (!app.methods.enableButtonClicked()) {
      return
    }

    if (!opts.target.dataset.istap) {
      return
    }

    that.data.signInListData = []

    let params = {
      courseId: opts.target.dataset.id,
    }

    let success = function (res) {
      that.setData({
        signInListData: res.data.result
      })
      that.onPopupToggle()
    }

    let fail = function (msg) {
       dd.showToast({
        type: 'fail',
        content: msg
      })
    }

    setTimeout(function() {
      dd.hideLoading()
      syllabus.signInList(params, success, fail)
    }, 800)
  },

  /**
   * tab选项被点击回调
   */
  handleChange(index) {
    this.setData({
      activeTab: index,
    });
  },

  /**
   * tab选项改变回调
   */
  onChange(index) {
    let that = this
    that.setData({
      activeTab: index
    });

    switch (that.data.manageTabs[index].anchor) {
      case 0:
        that.data.page = 1
        that.getList()
        break;
      case 1:
        that.initReleaseData()
        break;
      case 2:
        that.data.page = 1
        that.getList()
        break;
      case 3:
        console.log('切换至扫一扫')
        break;
      case 4:
        that.data.page = 1
        that.getList()
        break;
      case 5:
        that.initReleaseData()
        break;
    }
  },

  /**
   * 加载下一页数据
   */
  onScrollToLower() {
    this.getList('next')
  },

  /**
   * 初始化发布课程页数据
   */
  initReleaseData() {
    let that = this

    that.setData({
      ceratedCourseTitle: '',
      ceratedCourseMaxPeople: '',
      ceratedCourseStartTime: '',
      ceratedCourseEndTime: '',
      activeCourseTypeIndex: 0,
      isPushMsgIndex: 0,
      ceratedClassesNumber: '',
      ceratedClassesName: '',
      ceratedClassesTeacherName: ''
    })
  },

  /**
   * 打开modal
   */
  openModal(opts) {
    this.setData({
      modalBtnTextArr: [
        {
          text: opts.ltext || '取消'
        },
        {
          text: opts.rtext || '确定'
        }
      ],
      modalTitle: opts.title || '',
      modalSubTitle: opts.subtitle || '',
      modalOpened: true,
      modalCallback: opts.cb || ''
    })
  },

  /**
   * modal框按钮点击回调
   */
  modalButtonClick(e) {
    let type = e.target.dataset.index
    if (type == 0) { // 关闭modal
      this.setData({
        modalOpened: false
      })
    } else {
      if (this.data.modalCallback && typeof this.data.modalCallback === 'function') {
        this.setData({
          modalOpened: false
        })
        this.data.modalCallback()
      }
    }
  },

  /**
   * 二维码弹窗关闭
   */
  qrcodeMaskClose() {
    this.setData({
      qrcodeMaskOpened: false
    })
    this.getList()
  },

  /**
   * 拉起扫一扫
   */
  openScan() {
    let that = this
    dd.scan({
      type: 'qr',
      success: (res) => {
      //   that.openModal({
      //   title: '温馨提示',
      //   subtitle: JSON.stringify(res.code),
      //   ltext: '我在想想',
      //   rtext: '确认发布',
      //   cb: function () {
      //     that.add()
      //   }
      // })
        let arr = res.code.split("|")

        if (arr[0] == 0) { // 签到二维码扫码
          that.sign({
            courseId: arr[2],
            studentUserId: arr[1]
          })
        }

        if (arr[0] == 2) { // 打榜认证
          that.setData({
            userRankId: arr[1], // 打榜用户id
            userRankInfoModal: true
          })
        }

        if (arr[0] == 3) { // 
          that.limuHX({
            userId: arr[1], // 扣除用户id
          })
        }
      }
    })
  },

  /**
   * 检测教练输入的打榜分数是否有效
   */
  checkRankScoreValid() {
    if (this.data.userScore) {
       let reg = /(^[1-9]\d*$)/;
       if  (!reg.test(this.data.userScore)) {
          dd.showToast({
            type: 'fail',
            content: '不合理的分数值,分数范围为1-120的正整数1'
          })
          return false
       } else {
         if (this.data.userScore <= 0 || this.data.userScore > 120) {
            dd.showToast({
            type: 'fail',
            content: '不合理的分数值,分数范围为1-120的正整数'
          })
          return false
         }
       }
    } else {
      dd.showToast({
        type: 'fail',
        content: '请输入打榜分数'
       })
      return false
    }

    return true
  },

  /**
   * 教练认证学员打榜积分
   */
  setUserRankScore() {
    let that = this

    if (!that.checkRankScoreValid()) {
      return
    }
    
    that.openModal({
      title: '提示',
      subtitle: '确定发起学员积分认证?',
      cb: function () {
        that.rankingCheck({
          id: that.data.userRankId,
          teacherUid: app.globalData.userInfo.id,
          sort: that.data.userScore
        })
      }
    })
  },

  /**
   * 用户输入打榜积分
   */
  iptEnterUserScore(e) {
    this.setData({
      userScore: e.detail.value
    })
  },

  /**
   * 关闭认证打榜信息弹窗
   */
  closeUserRankInfoModal() {
    this.setData({
      userRankInfoModal: false
    })
  },

  /**
   * 切换课程类型回调
   */
  setCourseTypeIndex(e) {
    this.setData({
      activeCourseTypeIndex: e.detail.value
    });
  },

  /**
   * 切换是否通知钉钉群回调
   */
  setIsPushMsgIndex(e) {
    this.setData({
      isPushMsgIndex: e.detail.value
    });
  },

  /**
   * 切换报名列表/班级人员列表浮层
   */
  onPopupToggle() {
    this.setData({
      onPopup: !this.data.onPopup
    })
  },

  /**
   * 设置课程开始时间
   */
  setCourseBeginTime() {
    console.log('setCourseBeginTime')
    let that = this
    dd.datePicker({
      format: 'yyyy-MM-dd HH:mm',
      currentDate: that.data.serverTime,
      success: (res) => {
        that.setData({
          ceratedCourseStartTime: res.date
        })
      }
    })
  },

  /**
   * 设置课程开始时间
   */
  setCourseEndTime() {
    console.log('setCourseEndTime')
    let that = this
    dd.datePicker({
      format: 'yyyy-MM-dd HH:mm',
      currentDate: that.data.serverTime,
      success: (res) => {
        that.setData({
          ceratedCourseEndTime: res.date
        })
      }
    })
  },

  /**
   * 发布课程所有输入框失去焦点事件
   */
  createCourseIptBlur(e) {
    let that = this
    if (e.target.dataset.type == 'title') {
      that.setData({
        ceratedCourseTitle: e.detail.value
      })
    }

    if (e.target.dataset.type == 'people') {
      that.setData({
        ceratedCourseMaxPeople: e.detail.value
      })
    }
  },

  /**
   * 创建班级所有输入框失去焦点事件
   */
  createClassesIptBlur(e) {
    let that = this
    if (e.target.dataset.type == 'classes-number') {
      that.setData({
        ceratedClassesNumber: e.detail.value
      })
    }

    if (e.target.dataset.type == 'classes-name') {
      that.setData({
        ceratedClassesName: e.detail.value
      })
    }

    if (e.target.dataset.type == 'teacher-name') {
      that.setData({
        ceratedClassesTeacherName: e.detail.value
      })
    }
  },

  /**
   * 发布课程
   */
  pushCourse() {
    let that = this
    if (that.data.ceratedCourseTitle.replace(/\s/g, "").length <=0 ||
        that.data.ceratedCourseMaxPeople.replace(/\s/g, "").length <=0 ||
        that.data.ceratedCourseStartTime.replace(/\s/g, "").length <=0 ||
        that.data.ceratedCourseEndTime.replace(/\s/g, "").length <=0) {
          dd.showToast({
            type: 'fail',
            content: '请将课程信息补充完整！'
          })

          return
    }

    if (app.methods.enableButtonClicked()) {
      that.openModal({
        title: '温馨提示',
        subtitle: '课程发布过后将不可修改，请您确认课程信息无误后在执行发布',
        ltext: '我在想想',
        rtext: '确认发布',
        cb: function () {
          that.add()
        }
      })
    }
  },

  /**
   * 新开班级
   */
  pushClasses() {
    let that = this
    if (that.data.ceratedClassesNumber.replace(/\s/g, "").length <=0 ||
        that.data.ceratedClassesName.replace(/\s/g, "").length <=0 ||
        that.data.ceratedClassesTeacherName.replace(/\s/g, "").length <=0) {
          dd.showToast({
            type: 'fail',
            content: '请将班级信息补充完整！'
          })

          return
    }

    if (app.methods.enableButtonClicked()) {
      that.openModal({
        title: '温馨提示',
        subtitle: '班级创立过后将不可修改，请您确认课程信息无误后在执行发布',
        ltext: '我在想想',
        rtext: '确认开班',
        cb: function () {
          that.add()
        }
      })
    }
  }
})



